package com.ny.demo518;

import java.util.Iterator;
import java.util.List;
import java.util.Set;

public class TestSet {
    public void addEmp(Set<Emp> set, Emp emp){
        set.add(emp);
    }
    public void findAllEmp(Set<Emp> set){
        for (Emp emp:set){
            System.out.println(emp);
        }
    }
    public Emp findAllEmpName(Set<Emp> set, String empName){
        for (Emp emp:set){
            if (empName.equals(emp.getName())){
                return emp;
            }
        }
        return null;
    }
    public void deleteEmp(Set<Emp> set, String empNumber){
        Iterator<Emp> iterator= set.iterator();
        while (iterator.hasNext()){
            Emp emp=iterator.next();
            if (empNumber.equals(emp.getNumber())){
                iterator.remove();
            }
        }
    }
    public Emp findAllEmpNumber(Set<Emp> set, String empNumber){
        for (Emp emp:set){
            if (empNumber.equals(emp.getNumber())){
                return emp;
            }
        }
        return null;
    }
    public void updateEmp(Set<Emp> set,int empAge,Emp emp) {
        emp.setAge(empAge);
    }
}
